package com.puti.doctor.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.puti.common.core.domain.R;
import com.puti.doctor.domian.SeckillEvaluate;
import com.puti.doctor.service.ISeckillEvaluateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.puti.common.log.annotation.Log;
import com.puti.common.log.enums.BusinessType;
import com.puti.common.security.annotation.PreAuthorize;

import com.puti.common.core.web.controller.BaseController;
import com.puti.common.core.web.domain.AjaxResult;
import com.puti.common.core.utils.poi.ExcelUtil;
import com.puti.common.core.web.page.TableDataInfo;

/**
 * 秒杀-评价 秒杀-评价Controller
 *
 * @author puti
 * @date 2021-04-21
 */
@CrossOrigin
@RestController
@RequestMapping("/evaluate")
public class SeckillEvaluateController extends BaseController
{
    @Autowired
    private ISeckillEvaluateService seckillEvaluateService;

    /**
     * 查询秒杀-评价 秒杀-评价列表
     */
    @PreAuthorize(hasPermi = "system:evaluate:list")
    @GetMapping("/list")
    public TableDataInfo list(SeckillEvaluate seckillEvaluate)
    {
        startPage();
        List<SeckillEvaluate> list = seckillEvaluateService.selectSeckillEvaluateList(seckillEvaluate);
        return getDataTable(list);
    }


    //全部评价
    @GetMapping("/allreviews")
    public TableDataInfo allreviews(SeckillEvaluate seckillEvaluate)
    {
        startPage();
        List<SeckillEvaluate> list = seckillEvaluateService.selectallreviews(seckillEvaluate);
        return getDataTable(list);
    }
    /**
     * 导出秒杀-评价 秒杀-评价列表
     */

    /**
     * 导出秒杀-评价 秒杀-评价列表
     */
    @PreAuthorize(hasPermi = "system:evaluate:export")
    @Log(title = "秒杀-评价 秒杀-评价", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SeckillEvaluate seckillEvaluate) throws IOException
    {
        List<SeckillEvaluate> list = seckillEvaluateService.selectSeckillEvaluateList(seckillEvaluate);
        ExcelUtil<SeckillEvaluate> util = new ExcelUtil<SeckillEvaluate>(SeckillEvaluate.class);
        util.exportExcel(response, list, "秒杀-评价 秒杀-评价数据");
    }

    /**
     * 获取秒杀-评价 秒杀-评价详细信息
     */
    @GetMapping(value = "/{evaluateId}")
    public AjaxResult getInfo(@PathVariable("evaluateId") Long evaluateId)
    {
        return AjaxResult.success(seckillEvaluateService.selectSeckillEvaluateById(evaluateId));
    }

    /**
     * 新增秒杀-评价 秒杀-评价
     */
    @Log(title = "秒杀-评价 秒杀-评价", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SeckillEvaluate seckillEvaluate)
    {
        return toAjax(seckillEvaluateService.insertSeckillEvaluate(seckillEvaluate));
    }

    /**
     * 修改秒杀-评价 秒杀-评价
     */
    @Log(title = "秒杀-评价 秒杀-评价", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SeckillEvaluate seckillEvaluate)
    {
        return toAjax(seckillEvaluateService.updateSeckillEvaluate(seckillEvaluate));
    }

    /**
     * 删除秒杀-评价 秒杀-评价
     */
    @Log(title = "秒杀-评价 秒杀-评价", businessType = BusinessType.DELETE)
	@DeleteMapping("/{evaluateIds}")
    public AjaxResult remove(@PathVariable Long[] evaluateIds)
    {
        return toAjax(seckillEvaluateService.deleteSeckillEvaluateByIds(evaluateIds));
    }

    @GetMapping("/puti-kill/{patientId}/{goodsCodId}")
    public List<SeckillEvaluate> selectSeckillEvaluate(long patientId, String goodsCodId){
        return seckillEvaluateService.selectSeckillEvaluate(patientId,goodsCodId);
    }


}
